/*
 * Copyright (c) 2009 by unreserved.org.
 * All rights reserved.
 */

package org.unreserved.ladderplot;

public class Label implements Event {
    protected String text;
    /** Object that this Label is tethered to. */
    protected HAnchor anchor;
    /** Position on HAnchor that this label is attached to. */
    protected XPosition anchorPos = XPosition.LEFT;
    /** Position on Label that attaches to the HAnchor. */
    protected XPosition labelPos = XPosition.LEFT;
    
    protected Alignment textAlignment = Alignment.LEFT;
    
    public Label(String text, HAnchor anchor) {
        this.text = text;
        this.anchor = anchor;
    }
    
    public Label(String text) {
        this.text = text;
    }
    
    public String getText() {
        return text;
    }
    
    public HAnchor getAnchor() {
        return anchor;
    }
    
    public void setAnchorPos(XPosition anchorPos) {
        this.anchorPos = anchorPos;
    }
    
    public XPosition getAnchorPos() {
        return anchorPos;
    }
    
    public void setLabelPos(XPosition labelPos) {
        this.labelPos = labelPos;
    }
    
    public XPosition getLabelPos() {
        return labelPos;
    }
    
    public void setTextAlignment(Alignment a) {
        this.textAlignment = a;
    }
    
    public Alignment getTextAlignment() {
        return textAlignment;
    }
    
    // from Event
    public void accept(ModelVisitor visitor) {
        visitor.visit(this);
    }
    
    public String toString() {
        return "Label[" + text +
            ",anchor=" + anchor +
            ",anchorPos=" + anchorPos +
            ",labelPos=" + labelPos +
            ",textAlignment=" + textAlignment + "]";
    }
}
